Imports System.Math

Public Class dpicalculations

    Public TargetDPI, PrimYarnsinHd, PrimNoofYarns, SecYarnsinHd, SecNoofYarns, TierID, Foot As Integer
    Public PrimStrengthGperDen, SecStrengthGperDen, PrimModTensilegperDen, SecModTensilegperDen As Integer
    Public EuroperKg, CostperSqM, LOA, InputAWS, InputDPI, Orientation, MinTWS, MaxTWS As Integer
    Public PrimDen, SecDen, Usage, Code2, ReefNumber, ConstructionID, InputMainHAtt, InputMainTAtt As Integer
    Public InputHeadHAtt, InputHeadTAtt, SlideOffset, HankOffset, MaxHoist As Integer
    Public GenSailTypeID, BattenNumber, LineItemMultiplier, ClothDiscount, EMTReefs As Integer
    Public CMMperDPI, Leech, Luff, LPorFoot, LeFtGrp, LuGrp, LuFtGrp, FtGrp, CombWidth As Double
    Public MaxUpwBoatSpeed, TableWidth, TableLength, RampDistance, TurnAround, TurnSpeed As Double
    Public FullSpeedX, FullSpeedY, PlantAvailTime, EuroperSqM1, EuroperSqM2, Profit, YarnCF As Double
    Public MarketCF, TierCF, UsageCF, MaxAWSFactor, MinAWSFactor, AreaFactor, BaseAdjuster As Double
    Public SailAdjuster, HeadAdjuster, OptionAdjuster, PriceFactor, SailTypeCF, BoatTypeFactor As Double
    Public OptionPriceFactor, DPIadjuster, UsageAdjuster, InputArea, LoadFactorAdjuster As Double
    Public TransportMultiplier, CutOnlyMultiplier, RMMultiplier, CMMultiplier, HeadMultiplier As Double
    Public RMAdder, CMAdder, HeadAdder As Double
    Public BoatSpeedAdjuster, I, J, P, ValE, FindLuff, FindLP, VAT, PriceExVAT, NylonCMM As Double
    Public MainFootDeduction, ProductionTimeAdjustment, EMTAdjuster, CutOnlyPerc, SeamedOnlyPerc As Double
    Public NylonDPI, NylonPriceFactor, Leechin, DepositPaid, DepositPerc, FindPLuff, FindEFoot As Double
    Public Sundries, InputBRP, Py, Ey, ISP, SPL, STL, MembraneOnlyPerc, COMDPIPF, Weight As Double
    Public YarnPriceFactor, SailPriceFactor, DPIPriceFactor, UsagePriceFactor, SeasonalPF As Double
    Public OptionTot, ExchangeRate, Offer, LineItemPrice, Discount, PreOfferTotal, AccessoryPrice As Double
    Public SmallSailAdjuster, ClothPrice, ClothWidthFactor, SailCostFactor, TierAdjuster As Double
    Public HourlyRate, HoursUsedFactor, SurfaceTopPrice, SurfaceBottomPrice, DealerDiscount As Double
    Public DealerExchangeRate, ListPrice, CofMHoursAdjuster, MembraneFinishHours, InputCMM As Double
    Public PrimUnit, SecUnit, YarnType, FilmType, TierCode, UsageCode, ConstructionCode As String
    Public Multiplier, CodeLetter, SailCode As String
    Public Main, EMS, Nylon, MeasBandAltered, EMT, NotionalAreaUsed, SpecAdjustment, Mizzen As Boolean
    Public IsFurling, UseCalcAtts, FurlCode As Boolean

    Public WriteOnly Property CtlHeadAdder() As Double
        Set(ByVal value As Double)
            HeadAdder = value
        End Set
    End Property

    Public WriteOnly Property CtlCMAdder() As Double
        Set(ByVal value As Double)
            CMAdder = value
        End Set
    End Property

    Public WriteOnly Property CtlRMAdder() As Double
        Set(ByVal value As Double)
            RMAdder = value
        End Set
    End Property

    Public WriteOnly Property CtlHeadMultiplier() As Double
        Set(ByVal value As Double)
            HeadMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlCMMultiplier() As Double
        Set(ByVal value As Double)
            CMMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlRMMultiplier() As Double
        Set(ByVal value As Double)
            RMMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlCutOnlyMultiplier() As Double
        Set(ByVal value As Double)
            CutOnlyMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlTransportMultiplier() As Double
        Set(ByVal value As Double)
            TransportMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlWeight() As Double
        Set(ByVal value As Double)
            Weight = value
        End Set
    End Property

    Public WriteOnly Property CtlSeamedOnlyPerc() As Double
        Set(ByVal value As Double)
            SeamedOnlyPerc = value
        End Set
    End Property

    Public WriteOnly Property CtlCutOnlyPerc() As Double
        Set(ByVal value As Double)
            CutOnlyPerc = value
        End Set
    End Property

    Public WriteOnly Property CtlEMTAdjuster() As Double
        Set(ByVal value As Double)
            EMTAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlMainFootDeduction() As Double
        Set(ByVal value As Double)
            MainFootDeduction = value
        End Set
    End Property

    Public WriteOnly Property CtlProductionTimeAdjustment() As Double
        Set(ByVal value As Double)
            ProductionTimeAdjustment = value
        End Set
    End Property

    Public WriteOnly Property CtlFoot() As Integer
        Set(ByVal value As Integer)
            Foot = value
        End Set
    End Property

    Public WriteOnly Property CtlMaxHoist() As Integer
        Set(ByVal value As Integer)
            MaxHoist = value
        End Set
    End Property

    Public WriteOnly Property CtlSlideOffset() As Integer
        Set(ByVal value As Integer)
            SlideOffset = value
        End Set
    End Property

    Public WriteOnly Property CtlHankOffset() As Integer
        Set(ByVal value As Integer)
            HankOffset = value
        End Set
    End Property

    Public WriteOnly Property CtlUseCalcAtts() As Boolean
        Set(ByVal value As Boolean)
            UseCalcAtts = value
        End Set
    End Property

    Public WriteOnly Property CtlInputMainHAtt() As Integer
        Set(ByVal value As Integer)
            InputMainHAtt = value
        End Set
    End Property

    Public WriteOnly Property CtlInputMainTAtt() As Integer
        Set(ByVal value As Integer)
            InputMainTAtt = value
        End Set
    End Property

    Public WriteOnly Property CtlInputHeadHAtt() As Integer
        Set(ByVal value As Integer)
            InputHeadHAtt = value
        End Set
    End Property

    Public WriteOnly Property CtlInputHeadTAtt() As Integer
        Set(ByVal value As Integer)
            InputHeadTAtt = value
        End Set
    End Property

    Public WriteOnly Property CtlIsFurling() As Boolean
        Set(ByVal value As Boolean)
            IsFurling = value
        End Set
    End Property

    Public WriteOnly Property CtlTierID() As Integer
        Set(ByVal value As Integer)
            TierID = value
        End Set
    End Property

    Public WriteOnly Property CtlConstructionID() As Integer
        Set(ByVal value As Integer)
            ConstructionID = value
        End Set
    End Property

    Public WriteOnly Property CtlInputCMM() As Double
        Set(ByVal value As Double)
            InputCMM = value
        End Set
    End Property

    Public WriteOnly Property CtlFurlCode() As Boolean
        Set(ByVal value As Boolean)
            FurlCode = value
        End Set
    End Property

    Public WriteOnly Property CtlMembraneFinishHours() As Integer
        Set(ByVal value As Integer)
            MembraneFinishHours = value
        End Set
    End Property

    Public WriteOnly Property CtlCofMHoursAdjuster() As Integer
        Set(ByVal value As Integer)
            CofMHoursAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlEMTReefs() As Integer
        Set(ByVal value As Integer)
            EMTReefs = value
        End Set
    End Property

    Public WriteOnly Property CtlMizzen() As Boolean
        Set(ByVal value As Boolean)
            Mizzen = value
        End Set
    End Property

    Public WriteOnly Property CtlCOMDPIPF() As Double
        Set(ByVal value As Double)
            COMDPIPF = value
        End Set
    End Property

    Public WriteOnly Property CtlMembraneOnlyPerc() As Double
        Set(ByVal value As Double)
            MembraneOnlyPerc = value
        End Set
    End Property

    Public WriteOnly Property CtlPy() As Double
        Set(ByVal value As Double)
            Py = value
        End Set
    End Property

    Public WriteOnly Property CtlEy() As Double
        Set(ByVal value As Double)
            Ey = value
        End Set
    End Property

    Public WriteOnly Property CtlSPL() As Double
        Set(ByVal value As Double)
            SPL = value
        End Set
    End Property

    Public WriteOnly Property CtlSTL() As Double
        Set(ByVal value As Double)
            STL = value
        End Set
    End Property

    Public WriteOnly Property CtlISP() As Double
        Set(ByVal value As Double)
            ISP = value
        End Set
    End Property

    Public WriteOnly Property CtlInputBRP() As Double
        Set(ByVal value As Double)
            ListPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlListPrice() As Double
        Set(ByVal value As Double)
            ListPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlSundries() As Double
        Set(ByVal value As Double)
            Sundries = value
        End Set
    End Property

    Public WriteOnly Property CtlClothDiscount() As Integer
        Set(ByVal value As Integer)
            ClothDiscount = value
        End Set
    End Property

    Public WriteOnly Property CtlDealerExchangeRate() As Double
        Set(ByVal value As Double)
            DealerExchangeRate = value
        End Set
    End Property

    Public WriteOnly Property CtlDealerDiscount() As Double
        Set(ByVal value As Double)
            DealerDiscount = value
        End Set
    End Property

    Public WriteOnly Property CtlpecAdjustment() As Boolean
        Set(ByVal value As Boolean)
            SpecAdjustment = value
        End Set
    End Property

    Public WriteOnly Property CtlSurfaceTopPrice() As Double
        Set(ByVal value As Double)
            SurfaceTopPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlSurfaceBottomPrice() As Double
        Set(ByVal value As Double)
            SurfaceBottomPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlNotionalAreaused() As Boolean
        Set(ByVal value As Boolean)
            NotionalAreaUsed = value
        End Set
    End Property

    Public WriteOnly Property CtlHoursUsedFactor() As Double
        Set(ByVal value As Double)
            HoursUsedFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlHourlyRate() As Double
        Set(ByVal value As Double)
            HourlyRate = value
        End Set
    End Property

    Public WriteOnly Property CtlTierAdjuster() As Double
        Set(ByVal value As Double)
            TierAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlSailCostFactor() As Double
        Set(ByVal value As Double)
            SailCostFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlClothWidthFactor() As Double
        Set(ByVal value As Double)
            ClothWidthFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlClothPrice() As Double
        Set(ByVal value As Double)
            ClothPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlEMT() As Boolean
        Set(ByVal value As Boolean)
            EMT = value
        End Set
    End Property

    Public WriteOnly Property CtlSmallSailAdjuster() As Double
        Set(ByVal value As Double)
            SmallSailAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlAccessoryPrice() As Double
        Set(ByVal value As Double)
            AccessoryPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlPreOfferTotal() As Double
        Set(ByVal value As Double)
            PreOfferTotal = value
        End Set
    End Property

    Public WriteOnly Property CtlLineItemPrice() As Double
        Set(ByVal value As Double)
            LineItemPrice = value
        End Set
    End Property

    Public WriteOnly Property CtlOffer() As Double
        Set(ByVal value As Double)
            Offer = value
        End Set
    End Property

    Public WriteOnly Property CtlReefNumber() As Integer
        Set(ByVal value As Integer)
            ReefNumber = value
        End Set
    End Property

    Public WriteOnly Property CtlLineItemMultiplier() As Integer
        Set(ByVal value As Integer)
            LineItemMultiplier = value
        End Set
    End Property

    Public WriteOnly Property CtlSailCode() As String
        Set(ByVal value As String)
            SailCode = value
        End Set
    End Property

    Public WriteOnly Property CtlDepositPerc() As Double
        Set(ByVal value As Double)
            DepositPerc = value
        End Set
    End Property

    Public WriteOnly Property CtlDepositPaid() As Double
        Set(ByVal value As Double)
            DepositPaid = value
        End Set
    End Property

    Public WriteOnly Property CtlLeechin() As Double
        Set(ByVal value As Double)
            Leechin = value
        End Set
    End Property

    Public WriteOnly Property CtlNylonPriceFactor() As Double
        Set(ByVal value As Double)
            NylonPriceFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlMeasBandAltered() As Boolean
        Set(ByVal value As Boolean)
            MeasBandAltered = value
        End Set
    End Property

    Public WriteOnly Property CtlNylon() As Boolean
        Set(ByVal value As Boolean)
            Nylon = value
        End Set
    End Property

    Public WriteOnly Property CtlNylonDPI() As Double
        Set(ByVal value As Double)
            NylonDPI = value
        End Set
    End Property

    Public WriteOnly Property CtlNylonCMM() As Double
        Set(ByVal value As Double)
            NylonCMM = value
        End Set
    End Property

    Public WriteOnly Property CtlConstructionCode() As String
        Set(ByVal value As String)
            ConstructionCode = value
        End Set
    End Property

    Public WriteOnly Property CtlUsageCode() As String
        Set(ByVal value As String)
            UsageCode = value
        End Set
    End Property

    Public WriteOnly Property CtlCodeLetter() As String
        Set(ByVal value As String)
            CodeLetter = value
        End Set
    End Property

    Public WriteOnly Property CtlCode2() As Integer
        Set(ByVal value As Integer)
            Code2 = value
        End Set
    End Property

    Public WriteOnly Property CtlTierCode() As String
        Set(ByVal value As String)
            TierCode = value
        End Set
    End Property

    Public WriteOnly Property CtlPriceExVAT() As Double
        Set(ByVal value As Double)
            PriceExVAT = value
        End Set
    End Property

    Public WriteOnly Property CtlVAT() As Double
        Set(ByVal value As Double)
            VAT = value
        End Set
    End Property

    Public WriteOnly Property CtlFindLuff() As Double
        Set(ByVal value As Double)
            FindLuff = value
        End Set
    End Property

    Public WriteOnly Property CtlFindLp() As Double
        Set(ByVal value As Double)
            FindLP = value
        End Set
    End Property

    Public WriteOnly Property CtlFindPLuff() As Double
        Set(ByVal value As Double)
            FindPLuff = value
        End Set
    End Property

    Public WriteOnly Property CtlFindEFoot() As Double
        Set(ByVal value As Double)
            FindEFoot = value
        End Set
    End Property

    Public WriteOnly Property CtlI() As Double
        Set(ByVal value As Double)
            I = value
        End Set
    End Property

    Public WriteOnly Property CtlJ() As Double
        Set(ByVal value As Double)
            J = value
        End Set
    End Property

    Public WriteOnly Property CtlP() As Double
        Set(ByVal value As Double)
            P = value
        End Set
    End Property

    Public WriteOnly Property CtlValE() As Double
        Set(ByVal value As Double)
            ValE = value
        End Set
    End Property

    Public WriteOnly Property CtlBoatSpeedAdjuster() As Double
        Set(ByVal value As Double)
            BoatSpeedAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlLoadFactorAdjuster() As Double
        Set(ByVal value As Double)
            LoadFactorAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlEMS() As Boolean
        Set(ByVal value As Boolean)
            EMS = value
        End Set
    End Property

    Public WriteOnly Property CtlDiscount() As Double
        Set(ByVal value As Double)
            Discount = value
        End Set
    End Property

    Public WriteOnly Property CtlExchangeRate() As Double
        Set(ByVal value As Double)
            ExchangeRate = value
        End Set
    End Property

    Public WriteOnly Property CtlSeasonalPF() As Double
        Set(ByVal value As Double)
            SeasonalPF = value
        End Set
    End Property

    Public WriteOnly Property CtlOptionTot() As Double
        Set(ByVal value As Double)
            OptionTot = value
        End Set
    End Property


    Public WriteOnly Property CtlYarnPriceFactor() As Double
        Set(ByVal value As Double)
            YarnPriceFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlSailPriceFactor() As Double
        Set(ByVal value As Double)
            SailPriceFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlDPIPriceFactor() As Double
        Set(ByVal value As Double)
            DPIPriceFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlUsagePriceFactor() As Double
        Set(ByVal value As Double)
            UsagePriceFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlGenSailTypeID() As Integer
        Set(ByVal value As Integer)
            GenSailTypeID = value
        End Set
    End Property

    Public WriteOnly Property CtlBattenNumber() As Integer
        Set(ByVal value As Integer)
            BattenNumber = value
        End Set
    End Property

    Public WriteOnly Property CtlMain() As Boolean
        Set(ByVal value As Boolean)
            Main = value
        End Set
    End Property

    Public WriteOnly Property CtlTargetDPI() As Integer
        Set(ByVal value As Integer)
            TargetDPI = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimDen() As Integer
        Set(ByVal value As Integer)
            PrimDen = value
        End Set
    End Property

    Public WriteOnly Property CtlSecDen() As Integer
        Set(ByVal value As Integer)
            SecDen = value
        End Set
    End Property

    Public WriteOnly Property CtlMinTWS() As Integer
        Set(ByVal value As Integer)
            MinTWS = value
        End Set
    End Property

    Public WriteOnly Property CtlMaxTWS() As Integer
        Set(ByVal value As Integer)
            MaxTWS = value
        End Set
    End Property

    Public WriteOnly Property CtlOrientation() As Integer
        Set(ByVal value As Integer)
            Orientation = value
        End Set
    End Property

    Public WriteOnly Property CtlLOA() As Integer
        Set(ByVal value As Integer)
            LOA = value
        End Set
    End Property

    Public WriteOnly Property CtlInputAWS() As Integer
        Set(ByVal value As Integer)
            InputAWS = value
        End Set
    End Property

    Public WriteOnly Property CtlInputDPI() As Integer
        Set(ByVal value As Integer)
            InputDPI = value
        End Set
    End Property

    Public WriteOnly Property CtlEuroperKg() As Integer
        Set(ByVal value As Integer)
            EuroperKg = value
        End Set
    End Property

    Public WriteOnly Property CtlCostperSqM() As Integer
        Set(ByVal value As Integer)
            CostperSqM = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimModTensilegperDen() As Integer
        Set(ByVal value As Integer)
            PrimModTensilegperDen = value
        End Set
    End Property

    Public WriteOnly Property CtlSecModTensilegperDen() As Integer
        Set(ByVal value As Integer)
            SecModTensilegperDen = value
        End Set
    End Property

    Public WriteOnly Property CtlSecStrengthgperden() As Integer
        Set(ByVal value As Integer)
            SecStrengthGperDen = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimStrengthgperden() As Integer
        Set(ByVal value As Integer)
            PrimStrengthGperDen = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimNoofYarns() As Integer
        Set(ByVal value As Integer)
            PrimNoofYarns = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimYarnsinHd() As Integer
        Set(ByVal value As Integer)
            PrimYarnsinHd = value
        End Set
    End Property

    Public WriteOnly Property CtlSecNoofYarns() As Integer
        Set(ByVal value As Integer)
            SecNoofYarns = value
        End Set
    End Property

    Public WriteOnly Property CtlSecYarnsinHd() As Integer
        Set(ByVal value As Integer)
            SecYarnsinHd = value
        End Set
    End Property

    Public WriteOnly Property CtlCombWidth() As Integer
        Set(ByVal value As Integer)
            CombWidth = value
        End Set
    End Property

    Public WriteOnly Property CtlMaxAWSFactor() As Double
        Set(ByVal value As Double)
            MaxAWSFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlBoatTypeFactor() As Double
        Set(ByVal value As Double)
            BoatTypeFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlBaseAdjuster() As Double
        Set(ByVal value As Double)
            BaseAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlOptionAdjuster() As Double
        Set(ByVal value As Double)
            OptionAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlSailAdjuster() As Double
        Set(ByVal value As Double)
            SailAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlDPIadjuster() As Double
        Set(ByVal value As Double)
            DPIadjuster = value
        End Set
    End Property


    Public WriteOnly Property CtlUsageAdjuster() As Double
        Set(ByVal value As Double)
            UsageAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlHeadAdjuster() As Double
        Set(ByVal value As Double)
            HeadAdjuster = value
        End Set
    End Property

    Public WriteOnly Property CtlAreaFactor() As Double
        Set(ByVal value As Double)
            AreaFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlMinAWSFactor() As Double
        Set(ByVal value As Double)
            MinAWSFactor = value
        End Set
    End Property

    Public WriteOnly Property CtlTableWidth() As Double
        Set(ByVal value As Double)
            TableWidth = value
        End Set
    End Property

    Public WriteOnly Property CtlPlantAvailTime() As Double
        Set(ByVal value As Double)
            PlantAvailTime = value
        End Set
    End Property

    Public WriteOnly Property CtlEuroperSqM1() As Double
        Set(ByVal value As Double)
            EuroperSqM1 = value
        End Set
    End Property

    Public WriteOnly Property CtlEuroperSqM2() As Double
        Set(ByVal value As Double)
            EuroperSqM2 = value
        End Set
    End Property

    Public WriteOnly Property CtlTableLength() As Double
        Set(ByVal value As Double)
            TableLength = value
        End Set
    End Property

    Public WriteOnly Property CtlRampDistance() As Double
        Set(ByVal value As Double)
            RampDistance = value
        End Set
    End Property

    Public WriteOnly Property CtlTurnAround() As Double
        Set(ByVal value As Double)
            TurnAround = value
        End Set
    End Property

    Public WriteOnly Property CtlTurnSpeed() As Double
        Set(ByVal value As Double)
            TurnSpeed = value
        End Set
    End Property

    Public WriteOnly Property CtlMaxUpwBoatSpeed() As Double
        Set(ByVal value As Double)
            MaxUpwBoatSpeed = value
        End Set
    End Property

    Public WriteOnly Property CtlCMMperDPI() As Double
        Set(ByVal value As Double)
            CMMperDPI = value
        End Set
    End Property

    Public WriteOnly Property CtlLeFtGrp() As Double
        Set(ByVal value As Double)
            LeFtGrp = value
        End Set
    End Property

    Public WriteOnly Property CtlLuGrp() As Double
        Set(ByVal value As Double)
            LuGrp = value
        End Set
    End Property

    Public WriteOnly Property CtlLuFtGrp() As Double
        Set(ByVal value As Double)
            LuFtGrp = value
        End Set
    End Property

    Public WriteOnly Property CtlFtGrp() As Double
        Set(ByVal value As Double)
            FtGrp = value
        End Set
    End Property

    Public WriteOnly Property CtlLeech() As Double
        Set(ByVal value As Double)
            Leech = value
        End Set
    End Property

    Public WriteOnly Property CtlLuff() As Double
        Set(ByVal value As Double)
            Luff = value
        End Set
    End Property

    Public WriteOnly Property CtlLporFoot() As Double
        Set(ByVal value As Double)
            LPorFoot = value
        End Set
    End Property

    Public WriteOnly Property CtlInputArea() As Double
        Set(ByVal value As Double)
            InputArea = value
        End Set
    End Property

    Public WriteOnly Property CtlFullSpeedX() As Double
        Set(ByVal value As Double)
            FullSpeedX = value
        End Set
    End Property

    Public WriteOnly Property CtlFullSpeedY() As Double
        Set(ByVal value As Double)
            FullSpeedY = value
        End Set
    End Property

    Public WriteOnly Property CtlPrimUnit() As String
        Set(ByVal value As String)
            PrimUnit = value
        End Set
    End Property

    Public WriteOnly Property Ctlusage() As Integer
        Set(ByVal value As Integer)
            Usage = value
        End Set
    End Property

    Public WriteOnly Property CtlSecUnit() As String
        Set(ByVal value As String)
            SecUnit = value
        End Set
    End Property

    Public WriteOnly Property CtlYarnType() As String
        Set(ByVal value As String)
            YarnType = value
        End Set
    End Property

    Public WriteOnly Property CtlFilmType() As String
        Set(ByVal value As String)
            FilmType = value
        End Set
    End Property
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Sail Size Input Sheet calculation
    Function DPIMeasBndmin() ' Q32
        Return Round(DPIMeasBndInchin() / 12 / 3.281, 2)
    End Function

    Function InputLeechin()
        Return (Leechin * 3.281 * 12)
    End Function

    Function DPIMeasBndInchin() ' Q30
        Return Round((DPIMeasBndMup() * System.Math.Tan(0.43633)) * 3.281 * 12, 0)
    End Function

    Function DPIMeasBndMup() ' Q29
        '    If UpLeech = 16.6 Then
        Return Round(Leech * 0.16667, 3)
        '     Else
        '         Return Round(Leech * (UpLeech / 100), 3)
        '     End If
    End Function

    Function CalcLeech()
        If Main Then
            Return Sqrt((Luff) ^ 2 + (LPorFoot) ^ 2)
        Else
            Return Luff * 0.95
        End If
    End Function

    Function CalcArea() ' D16
        Return AreaFactor * (Luff * LPorFoot / 2)
    End Function

    Function NotionalArea()
        Return CalcArea() + (CalcArea() * (13 / 100))
    End Function

    Function LoadFactor() ' D19
        'Return ((Luff ^ 2.05) / LPorFoot) * (0.000001 * LOA ^ 3 + 0.0001 * LOA ^ 2 - 0.0075 * LOA + 1.0954)
        'Return ((Luff ^ 2) / LPorFoot) * (0.000001 * LOA ^ 3 + 0.0001 * LOA ^ 2 - 0.0075 * LOA + 1.0954) * LoadFactorAdjuster
        If TierID <> 21 And TierID <> 20 Then
            Return ((Luff ^ 2) / LPorFoot) * LoadFactorAdjuster
        Else
            Return (((Luff ^ 2) / LPorFoot) * LoadFactorAdjuster) * 0.8
        End If
    End Function

    Function LeFtPasses() ' D30
        Return TotalPasses() * LeFtGrp
    End Function

    Function LuPasses() ' D31
        Return TotalPasses() * LuGrp
    End Function

    Function LuFtPasses() ' D32
        Return TotalPasses() * LuFtGrp
    End Function

    Function FtPasses() ' D33
        Return TotalPasses() * FtGrp
    End Function

    Function BaseCMM() 'D43
        If Main = True Then
            'Return 1.21 * LoadFactor() ^ 1.2
            Return Round((0.0072 * LoadFactor() * InputAWS ^ 2) ^ 0.86, 2)
        Else
            If InputAWS > 15 Then
                Return Round((0.0072 * LoadFactor() * InputAWS ^ 2) ^ 0.926 / (InputAWS - 14) ^ 0.13, 2)
            Else
                Return Round((0.0072 * LoadFactor() * InputAWS ^ 2) ^ 0.926, 2)
            End If
        End If
    End Function

    Function RequiredCMM() ' I19
        '        If Usage = 2 Then
        Return BaseCMM()
        '       Else
        '          Return BaseCMM() * 0.98
        '     End If
    End Function

    'Function CMMforAWSgt31() ' D46
    '    Return (0.3307 * LoadFactor() * (InputAWS) ^ 0.75) ^ 0.926
    'End Function

    'Function CMMforAWSgt27() ' D45
    '    Return (0.2043 * LoadFactor() * (InputAWS) ^ 0.89) ^ 0.926
    'End Function

    'Function CMMforAWSgt23() ' D44
    '    Return (0.1055 * LoadFactor() * (InputAWS) ^ 1.09) ^ 0.926
    'End Function

    'Function CMMforAWSgt19() ' D43
    '    Return (0.049 * LoadFactor() * (InputAWS) ^ 1.33) ^ 0.926
    'End Function

    'Function CMMforAWSgt15() ' D42
    '    Return (0.02 * LoadFactor() * (InputAWS) ^ 1.63) ^ 0.926
    'End Function

    'Function CMMforAWSlt15() ' D41
    '    Return (0.0072 * LoadFactor() * (InputAWS) ^ 2) ^ 0.926
    'End Function

    Function MembraneCMM() ' I25
        Return CMMperDPI * InputDPI / 1000
    End Function

    Function LeechSections() ' N10
        If Orientation = 1 Then
            Return 1
        Else
            Return Luff / UseableSailSpaceY()
        End If
    End Function

    Function FootSections() ' N11
        If Orientation = 1 Then
            Return LPorFoot / UseableSailSpaceY()
        Else
            Return 1
        End If
    End Function

    Function UseableSailSpaceY() ' S6
        Return TableWidth - (2 * TurnAround)
    End Function

    Function FullSpeedDistanceY()  ' S8
        Return UseableSailSpaceY() - (2 * RampDistance)
    End Function

    Function TADistance() ' S9 & S23
        Return (2 * RampDistance) + (2 * TurnAround)
    End Function

    Function FullSpeedTimeY()  ' S10
        Return FullSpeedDistanceY() / (FullSpeedY / 1000)
    End Function

    Function TATime()  ' S11 & S26
        Return TADistance() / (TurnSpeed / 1000)
    End Function

    Function UseableSailSpaceX() ' S19
        Return TableLength - (2 * TurnAround)
    End Function

    Function FullSpeedDistanceX()  ' S21
        Return UseableSailSpaceX() - (2 * RampDistance)
    End Function

    Function FullSpeedTimeX()  ' S25
        Return FullSpeedDistanceX() / (FullSpeedX / 1000)
    End Function
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Yarn Density Calculations

    Function CMM() ' E
        Return TargetDPI * CMMperDPI / 1000
    End Function

    Function YarnHeadoverPass() ' F
        Return TargetDPI / DPIperPass()
    End Function

    Function DPIperPass() ' AS
        Return TotCalcDenierperPass() / CombWidth
    End Function

    Function TotCalcDenierperPass() 'AR
        Return PrimCalcDenierperPass() + SecCalcDenierperPass()
    End Function

    Function PrimCalcDenierperPass() 'X
        Return PrimYarnsInput() * PrimDenier()
    End Function

    Function PrimDenier() ' S
        Return PrimGramsperM() * 9000
    End Function

    Function PrimYarnsInput() ' N
        If PrimYarnsinHd > 0 Then
            Return PrimYarnsinHd
        Else
            Return PrimNoofYarns
        End If
    End Function

    Function PrimGramsperM() ' R
        If PrimUnit = "dtx" Then
            Return PrimDen / 10000
        Else
            Return PrimDen / 9000
        End If
    End Function


    Function SecCalcDenierperPass() 'AL
        Return SecDenier() * SecYarnsInput()
    End Function

    Function SecDenier() ' AG
        Return SecGramsperM() * 9000
    End Function

    Function SecYarnsInput() ' AB
        If SecYarnsinHd > 0 Then
            Return SecYarnsinHd
        Else
            Return SecNoofYarns
        End If
    End Function

    Function SecGramsperM() ' AF
        If SecUnit = "dtx" Then
            Return SecDen / 10000
        Else
            Return SecDen / 9000
        End If
    End Function


    Function TotalPasses() ' G
        If MeasBandAltered = True Then
            Return Round(InputLeechin() / CombWidth * YarnHeadoverPass(), 0)
        Else
            Return Round(DPIMeasBndInchin() / CombWidth * YarnHeadoverPass(), 0)
        End If
    End Function

    Function CalcDPI() ' H
        If MeasBandAltered = True Then
            Return Round(TotalPasses() * TotCalcDenierperPass() / InputLeechin(), 0)
        Else
            Return Round(TotalPasses() * TotCalcDenierperPass() / DPIMeasBndInchin(), 0)
        End If
    End Function

    Function GroupMYarn() ' I
        Return Round(TotalPasses() * TotalYarns() * Leech * 1.13, 0)
    End Function

    Function TotalYarns() ' AO
        Return PrimYarnsInput() + SecYarnsInput()
    End Function

    Function GroupStrengthBLkg() ' J
        Return Round(Strengthkgperpass() * TotalPasses(), 0)
    End Function

    Function Strengthkgperpass() ' AT
        Return Round(SecStrengthkgperpass() + PrimStrengthkgperpass(), 0)
    End Function

    Function SecStrengthkgperpass() ' AM
        Return Round(SecCalcDenierperPass() * SecStrengthGperDen / 1000, 0)
    End Function

    Function PrimStrengthkgperpass() ' Y
        Return Round(PrimCalcDenierperPass() * PrimStrengthGperDen / 1000, 0)
    End Function

    Function GroupStrengthBLkgPrim() ' K
        Return Round(PrimStrengthkgperpass() * TotalPasses(), 0)
    End Function

    Function PrimStrengthkg() ' U
        Return Round(PrimStrengthGperDen * PrimDenier() / 1000, 2)
    End Function

    Function PrimModuluskg() ' W
        Return Round(PrimModTensilegperDen * PrimDenier() / 1000, 0)
    End Function

    Function SecModuluskg() ' AK
        Return Round(SecModTensilegperDen * SecDenier() / 1000, 0)
    End Function
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'AWS Sheet
    Function MinAWS() 'I
        If MaxUpwBoatSpeed = 0 Then
            Return Round(MinTWS + ((CalcBoatSpeed() * BoatSpeedAdjuster) * MinAWSFactor), 0)
        Else
            Return Round(MinTWS + ((MaxUpwBoatSpeed * BoatSpeedAdjuster) * MinAWSFactor), 0)
        End If
    End Function

    Function MaxAWS() 'J
        If MaxUpwBoatSpeed = 0 Then
            If GenSailTypeID = 3 Then
                Return Round(MaxTWS + ((CalcBoatSpeed()) * MaxAWSFactor), 0)
            Else
                Return Round(MaxTWS + ((CalcBoatSpeed() * BoatSpeedAdjuster) * MaxAWSFactor), 0)
            End If
        Else
            If GenSailTypeID = 3 Then
                'Return Round(MaxTWS + ((MaxUpwBoatSpeed) * MaxAWSFactor), 0)
                Return Round(MaxTWS + ((CalcBoatSpeed()) * MaxAWSFactor), 0)
            Else
                'Return Round(MaxTWS + ((MaxUpwBoatSpeed * BoatSpeedAdjuster) * MaxAWSFactor), 0)
                Return Round(MaxTWS + ((CalcBoatSpeed() * BoatSpeedAdjuster) * MaxAWSFactor), 0)
            End If
        End If
    End Function

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Costings

    Function TotalMetres() ' C
        Return Round(GroupMYarn() + (GroupMYarn() * 0.77) + (GroupMYarn() * 0.44), 0)
    End Function

    Function FullSpeedDistance() 'E
        If Orientation = 1 Then
            Return FullSpeedDistanceX() * Leech / UseableSailSpaceX()
        Else
            Return FullSpeedDistanceY()
        End If
    End Function

    Function FullSpeedTime()  ' G
        If Orientation = 1 Then
            Return Round(FullSpeedDistance() / (FullSpeedX / 1000), 0)
        Else
            Return Round(FullSpeedDistance() / (FullSpeedY / 1000), 0)
        End If
    End Function

    Function LeSinglePassTime() ' I
        Return Round(FullSpeedTime() + TATime(), 0)
    End Function

    Function LeTotalGrpMins() ' J
        Return Round((LeSinglePassTime() * TotalPasses()) / 60 * 1.123 * LeechSections(), 0)
    End Function

    Function LuGrpPasses() ' L
        Return Round(TotalPasses() * 0.761, 0)
    End Function

    Function LuSinglePassTime() ' Q
        Return Round((FullSpeedTime() + TATime()) * 1.1, 0)
    End Function

    Function LuTotalGrpMins() ' R
        Return Round((LuSinglePassTime() * LuGrpPasses()) / 60 * 1.123 * LeechSections(), 0)
    End Function

    Function FtGrpPasses() ' T
        Return Round(TotalPasses() * 0.75, 0)
    End Function

    Function FtFullSpeedDistance() ' U
        If Orientation = 1 Then
            Return FullSpeedDistanceY() * LPorFoot / UseableSailSpaceY()
        Else
            Return FullSpeedDistanceX() * LPorFoot / UseableSailSpaceX()
        End If
    End Function

    Function FtfullSpeedTime() ' W
        If Orientation = 1 Then
            Return Round(FtFullSpeedDistance() / (FullSpeedY / 1000), 0)
        Else
            Return Round(FtFullSpeedDistance() / (FullSpeedX / 1000), 0)
        End If
    End Function

    Function FtSinglePassTime() 'Y
        Return Round(FtfullSpeedTime() + TATime(), 0)
    End Function

    Function FtTotalGrpMins() 'Z
        Return Round((FtSinglePassTime() * FtGrpPasses()) / 60, 0)
    End Function

    Function TotalSailMins()  'AA
        Return LeTotalGrpMins() + LuTotalGrpMins() + FtTotalGrpMins()
    End Function

    Function TotalSailHrs() ' AB
        Return Round(TotalSailMins() / 60, 2)
    End Function

    Function TimepreSqM() ' AC
        Return TotalSailHrs() / InputArea
    End Function

    Function SqMCompleteperAnnum() ' AD
        Return PlantAvailTime / TimepreSqM()
    End Function

    Function PlantHrsCost() ' AE
        'Return PlantCost * TotalSailHrs()
        Return 136.3 * TotalSailHrs()
    End Function

    Function KgYarns() ' AG
        Return Round(TotalMetres() * PrimGramsperM() / 1000, 2)
    End Function

    Function YarnEuro() ' AI
        Return KgYarns() * EuroperKg
    End Function

    Function FilmsEuroperMSq() ' AJ
        Return EuroperSqM1 + EuroperSqM2
    End Function

    Function FilmsEuro() ' AK
        Return FilmsEuroperMSq() * InputArea
    End Function

    Function GlueEuro() 'AL
        Return InputArea * 0.333
    End Function

    Function MaterialsEuro() 'AM
        Return YarnEuro() + FilmsEuro() + GlueEuro()
    End Function

    Function TotalCosts() ' AN
        Return Round(PlantHrsCost() + MaterialsEuro(), 2)
    End Function

    Function TotalCostsperSqM() ' AO
        Return TotalCosts() / InputArea
    End Function

    Function FactorCost()
        Return Round(TotalCostsperSqM() * TierCF * MarketCF * YarnCF * SailTypeCF * Profit * UsageCF, 2)
    End Function

    Function SailCost()
        Return Round(FactorCost() * CalcArea(), 2)
    End Function

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    Function PrimCalcDenier()
        Return PrimYarnsInput() * PrimDenier()
    End Function

    Function SecCalcDenier()
        Return SecYarnsInput() * SecDenier()
    End Function

    Function PrimPercDenierPass()
        Dim PrimTemp As Double
        PrimTemp = Round(((PrimCalcDenierperPass() / TotCalcDenierperPass()) * 100) / 10, 0)
        Return (PrimTemp * 10)
    End Function

    Function SecPercDenierPass()
        Dim SecTemp As Double
        SecTemp = Round(((SecCalcDenierperPass() / TotCalcDenierperPass()) * 100) / 10, 0)
        Return (SecTemp * 10)
    End Function

    Function ExtraArea() 'C12
        Return (InputArea - CalcArea()) / (CalcArea() * 100)
    End Function

    Function CalcBoatSpeed()
        ' Return Sqrt(LOA * 0.9) * 1.34
        Return Round(Sqrt(LOA * 0.9) * 1.34 * BoatTypeFactor, 2)
    End Function

    Function ClothPriceSqm()
        Return ClothPrice * (1000 / ClothWidthFactor)
    End Function

    Function ClothHoursFactor()
        Return ((InputArea + SmallSailAdjuster) / HoursUsedFactor) * HourlyRate * TierAdjuster
    End Function

    Function ClothAreaPrice()
        Return (InputArea + SmallSailAdjuster) * SailCostFactor * ClothPriceSqm()
    End Function

    Function DCofMFabric()
        Return ((InputArea + SmallSailAdjuster) * (ClothPriceSqm() - (ClothPriceSqm() * (ClothDiscount / 100))) + (ClothHoursFactor() * CofMHoursAdjuster * ProductionTimeAdjustment) + Sundries) * BaseAdjuster * SailAdjuster * UsageAdjuster + (OptionTotal() * 0.33)
    End Function

    Function FCofMFabric()
        Return ((InputArea + SmallSailAdjuster) * (ClothPriceSqm() - (ClothPriceSqm() * (ClothDiscount / 100))) + (ClothHoursFactor() * ProductionTimeAdjustment) + Sundries) * BaseAdjuster * SailAdjuster * UsageAdjuster + (OptionTotal() * 0.33)
    End Function

    Function CofMMembrane()
        Return (InputArea * COMDPIPF * YarnPriceFactor * BaseAdjuster) + ((SurfaceTopPrice + SurfaceBottomPrice) * (InputArea)) + (EMTReefs * ((InputArea * COMDPIPF * YarnPriceFactor) / 10)) * CofMHoursAdjuster
    End Function

    Function BaseRetailPriceCloth()
        Return (ClothAreaPrice() + ClothHoursFactor()) * BaseAdjuster * SailAdjuster * UsageAdjuster
    End Function

    Function CutOnlyPrice()
        Return (((ClothAreaPrice() + (ClothHoursFactor() * CutOnlyPerc * CutOnlyMultiplier)) * BaseAdjuster * SailAdjuster * UsageAdjuster) + OptionTotal()) * DealerExchangeRate
    End Function

    Function SeamedOnlyPrice()
        Return (((ClothAreaPrice() + (ClothHoursFactor() * SeamedOnlyPerc * CutOnlyMultiplier)) * BaseAdjuster * SailAdjuster * UsageAdjuster) + OptionTotal()) * DealerExchangeRate
    End Function

    Function BaseRetailPrice()
        Return YarnPriceFactor * DPIadjuster * (InputArea + SmallSailAdjuster) * BaseAdjuster * SailAdjuster * UsageAdjuster * EMTAdjuster
    End Function

    Function SurfacePrice()
        Return (SurfaceTopPrice + SurfaceBottomPrice) * (InputArea + SmallSailAdjuster)
    End Function

    Function EMTFinishhours()
        Return (CofMMembrane() * MembraneFinishHours)
    End Function

    Function EMTCofM()
        Return CofMMembrane() + (CofMMembrane() * MembraneFinishHours)
    End Function

    Function MembraneOnlyPrice()
        Return EMTCofM() * MembraneOnlyPerc
    End Function

    Function BaseretailPriceAdjusted()
        If EMT = True Then
            If SurfacePrice() = 0 Then
                Return 0
            ElseIf BaseRetailPrice() = 0 Then
                Return 0
            Else
                Return BaseRetailPrice() + SurfacePrice()
            End If
        Else
            Return BaseRetailPriceCloth()
        End If

    End Function

    Function OptionCost()
        Select Case Multiplier
            Case "1"
                Return LPorFoot * OptionPriceFactor
            Case "2"
                If EMT = True Then
                    If SurfacePrice() = 0 Then
                        Return 0
                    ElseIf BaseRetailPrice() = 0 Then
                        Return 0
                    Else
                        Return BaseRetailPrice() * OptionPriceFactor
                    End If
                Else
                    Return InputBRP * OptionPriceFactor
                    'Return BaseRetailPriceCloth() * OptionPriceFactor
                End If
            Case "3"
                Return Luff * OptionPriceFactor
            Case "4"
                Return OptionPriceFactor
            Case "5"
                Return (InputArea + SmallSailAdjuster) * OptionPriceFactor
            Case Else
                Return 999999
        End Select
    End Function

    Function ReefCost()
        Select Case Multiplier
            Case "1"
                Return LPorFoot * OptionPriceFactor * ReefNumber
            Case "2"
                Return BaseretailPriceAdjusted() * OptionPriceFactor * ReefNumber
            Case "3"
                Return Luff * OptionPriceFactor * ReefNumber
            Case "4"
                Return OptionPriceFactor * ReefNumber
            Case "5"
                Return (InputArea + SmallSailAdjuster) * OptionPriceFactor * ReefNumber
            Case Else
                Return 999999
        End Select
    End Function

    Function BattenCost()
        Select Case EMS
            Case False
                Return LPorFoot * OptionPriceFactor * BattenNumber
            Case Else
                Return Luff * OptionPriceFactor * BattenNumber
        End Select
    End Function

    Function OptionTotal()
        Return Round((OptionTot) * OptionAdjuster, 2)
    End Function

    Function PreAdjustPrice()
        Return BaseretailPriceAdjusted() + OptionTotal()
    End Function

    Function ListDealerSeasonlPrice()
        Return (ListPrice * SeasonalPF) * DealerExchangeRate
    End Function

    Function ListDealerSeasonlMktPrice()
        Return (ListPrice * (((1 - SeasonalPF) / 2) + 1) * MarketCF) * DealerExchangeRate
    End Function

    Function ListDealermarketPrice()
        Return (ListPrice * MarketCF) * DealerExchangeRate
    End Function

    Function ListSeasonalPrice()
        Return ListPrice * SeasonalPF
    End Function

    Function ListSeasonalPriceCurr()
        Return ListPrice * SeasonalPF * ExchangeRate * MarketCF
    End Function

    Function ListMarketPriceCurr()
        Return ListPrice * ExchangeRate * MarketCF
    End Function

    Function ListMarketPrice()
        Return ListPrice * MarketCF
    End Function

    Function ListPriceCurr()
        Return ListPrice * ExchangeRate
    End Function

    Function SeasonalPrice1()
        Return PreAdjustPrice() * SeasonalPF * MarketCF
    End Function

    Function SeasonalAccessPrice1()
        Return AccessoryPrice '* SeasonalPF
    End Function

    Function SeasonalAccessPrice2()
        Return MarketAccessRetailPrice() '* SeasonalPF
    End Function

    Function MarketAccessRetailPrice()
        Return AccessoryPrice ' * ExchangeRate '* MarketCF
    End Function

    Function MarketAccessRetailPriceEuro()
        Return AccessoryPrice ' * MarketCF
    End Function

    Function SellingAccessPrice()
        Return SeasonalAccessPrice2() - (SeasonalAccessPrice2() * Discount / 100)
    End Function

    Function AccessLineItemTotal()
        Return SellingAccessPrice() * LineItemMultiplier
    End Function

    Function MarketRetailPrice()
        Return PreAdjustPrice() * ExchangeRate * MarketCF
    End Function

    Function MarketRetailPriceEuro()
        Return PreAdjustPrice() * MarketCF
    End Function

    Function DealerPreDiscount()
        Return PreAdjustPrice() * SeasonalPF
    End Function

    Function DealerPrice()
        Return (DealerPreDiscount() - (DealerPreDiscount() * DealerDiscount / 100)) * DealerExchangeRate
    End Function

    Function SeasonalPrice2()
        Return MarketRetailPrice() * SeasonalPF
    End Function

    Function DealerAccessPriceEuro()
        Return (MarketAccessRetailPriceEuro() - (MarketAccessRetailPriceEuro() * DealerDiscount / 100)) * DealerExchangeRate
    End Function

    Function DealerAccessPrice1()
        Return AccessoryPrice * SeasonalPF * DealerExchangeRate
    End Function

    Function DealerAccessPrice2()
        Return AccessoryPrice * DealerExchangeRate '* MarketCF 
    End Function

    Function DealerAccessPrice3()
        Return AccessoryPrice * DealerExchangeRate '* SeasonalPF * MarketCF
    End Function

    Function SellingPrice()
        Return SeasonalPrice2() - (SeasonalPrice2() * Discount / 100)
    End Function

    Function LineItemTotal()
        Return SellingPrice() * LineItemMultiplier
    End Function

    Function CalcLuff()
        Return I * FindLuff
    End Function

    Function CalcLP()
        Return J * FindLP
    End Function

    Function CalcPLuff()
        If Mizzen = False Then
            Return P * FindPLuff
        Else
            If Py > 0 Then
                Return Py * FindPLuff
            Else
                Return P * FindPLuff
            End If
        End If
    End Function

    Function CalcEFoot()
        If Mizzen = False Then
            Return ValE * FindEFoot
        Else
            If Ey > 0 Then
                Return Ey * FindEFoot
            Else
                Return ValE * FindEFoot
            End If
        End If
    End Function

    Function CalcSpinLuff()
        Return Sqrt((I ^ 2) + (J ^ 2)) * 0.95
    End Function

    Function CalcSpinFoot()
        Return CalcLP()
    End Function

    Function PriceIncVAT()
        Return PriceExVAT + (PriceExVAT * VAT)
    End Function

    Function LineitemIncVAT()
        Return LineItemPrice + (LineItemPrice * VAT)
    End Function

    Function OfferDiscount()
        Return 100 - (Offer / (PreOfferTotal + (PreOfferTotal * VAT)) * 100)
    End Function

    Function OfferLineItemPrice()
        Return LineItemPrice - (LineItemPrice * OfferDiscount() / 100)
    End Function

    Function DepositRequired()
        Return (DepositPerc * Offer)
    End Function

    Function DepositBalance()
        Return DepositRequired() - DepositPaid
    End Function

    Function Balance()
        Return Offer - DepositPaid
    End Function

    Function SailModelCode()
        Dim TempFurlcode As Integer
        If FurlCode = True Then
            TempFurlcode = 1
        Else
            TempFurlcode = 0
        End If
        Return CodeLetter & UsageCode & TierCode & TempFurlcode & Code2 & ConstructionCode ' New
        ' Return UsageCode & CodeLetter & TierCode & TempFurlcode & Code2 & ConstructionCode ' Old
    End Function

    Function FindWeight()
        Return Round(((TargetDPI) ^ 0.66 / 1.7) / 45, 2)
    End Function

    Function ClothWeight()
        '1 ozsysm = 42.83 gmsqm
        '1 gmsqm = .0233 ozsysm
        If GenSailTypeID = 3 Then
            Return Round((FindWeight() * 45 / 10), 0) * 1.665
        Else
            Return Round((FindWeight() * 45 / 10), 0) * 10
        End If
    End Function

    Function TransportWeight()
        If EMT = True Then
            If CodeLetter = "M" Then
                If UsageCode = "R" Then
                    Return Round((RMMultiplier * ((Weight * InputArea) + ((TargetDPI / 10) * InputArea) + RMAdder)) / 1000, 2)
                Else
                    Return Round((CMMultiplier * ((Weight * InputArea) + ((TargetDPI / 10) * InputArea) + CMAdder)) / 1000, 2)
                End If
            Else
                Return Round((HeadMultiplier * ((Weight * InputArea) + ((TargetDPI / 10) * InputArea) + HeadAdder)) / 1000, 2)
            End If
        Else
            Return Round((Weight * InputArea * TransportMultiplier) / 1000, 2)
        End If
    End Function

    Function NylonCalcCMM()
        Return Round(NylonCMM * NylonDPI / 1000, 1)
    End Function

    Function BiasStretch()
        Return Round((1 / InputCMM) * 0.2973, 8)
    End Function

    Function WarpStretch()
        Return Round((1 / InputCMM) * 0.09009, 8)
    End Function

    Function LuffStretch()
        If ConstructionID = 3 Then
            Return BiasStretch()
        Else
            Return WarpStretch()
        End If
    End Function

    Function FootStretch()
        If ConstructionID = 3 Then
            Return BiasStretch()
        Else
            Return WarpStretch()
        End If
    End Function

    Function LeechStretch()
        Return WarpStretch()
    End Function

    Function LuffFactor()
        If GenSailTypeID = 1 And EMS = True Then
            Return 0.995
            'Return 1
        ElseIf Usage = 2 And TierCode = "3" And GenSailTypeID = 1 Then
            Return 1.005
        ElseIf Usage = 2 And TierCode = "2" And GenSailTypeID = 1 Then
            Return 1.0025
        ElseIf Usage = 2 And TierCode = "1" And GenSailTypeID = 1 Then
            Return 1.001
        Else
            'Return 0.999
            Return 1
        End If
    End Function

    Function LuffDed()
        Return Luff * LuffStretch()
    End Function

    Function CutLuff()
        If GenSailTypeID = 3 Then
            Return Luff
        ElseIf GenSailTypeID = 1 Then
            Return (Luff - LuffDed()) * LuffFactor() - MainHeadAttachments() - MainTackAttachments()
        Else
            Return (Luff - LuffDed()) * LuffFactor() - HeadHeadAttachments() - HeadTackAttachments()
        End If
    End Function

    Function LeechDed()
        Return Leech * LeechStretch()
    End Function

    Function CutLeech()
        If GenSailTypeID = 3 Then
            Return Leech
        ElseIf GenSailTypeID = 2 Then
            Return Leech - LeechDed() - HeadHeadAttachments()
        Else
            Return Leech - LeechDed()
        End If
    End Function

    Function FootDed()
        Return LPorFoot * FootStretch()
    End Function

    Function CutFoot()
        If GenSailTypeID = 1 Then
            If IsFurling = False Then
                Return (LPorFoot - 25) - (LPorFoot * FootStretch()) - SlideOffset
            Else
                Return (LPorFoot) - (LPorFoot * FootStretch()) - SlideOffset
            End If
        ElseIf GenSailTypeID = 2 Then
            Return LPorFoot - FootDed() - HankOffset
        Else
            Return LPorFoot
        End If
    End Function

    Function MainHeadAttachments()
        '       If InputMainHAtt = 0 Then
        ' I() 'f UseCalcAtts = True Or Luff = 0 Then
        ' If IsFurling = False Then
        'Return 0
        '  Else
        ' Return 50
        ' End If
        'Else
        Return InputMainHAtt
        'End If
    End Function


    Function MainTackAttachments()
        '    '       If InputMainTAtt = 0 Then
        '    ' If UseCalcAtts = True Or Luff = 0 Then
        '    If IsFurling = False Then
        '        Return 0
        '    Else
        '        Return 50
        '    End If
        '    'Else
        Return InputMainTAtt
        '    'End If
    End Function

    Function HeadHeadAttachments()
        '       If InputHeadHAtt = 0 Then
        If UseCalcAtts = True Or Luff = 0 Then
            If IsFurling = False Then
                If Usage = 1 Then
                    Return 30
                Else
                    Return 10
                End If
            Else
                If Usage = 1 Then
                    Return 30
                Else
                    Return 10
                End If
            End If
        Else
            Return InputHeadHAtt
        End If
    End Function

    Function HeadTackAttachments()
        'If InputHeadTAtt = 0 Then
        If UseCalcAtts = True Or Luff = 0 Then
            If IsFurling = False Then
                Return 0
            Else
                Return 30
            End If
        Else
            Return InputHeadTAtt
        End If
    End Function

    Function MaxHoistFactor()
        If GenSailTypeID = 2 Then
            Return 0.99
        ElseIf GenSailTypeID = 1 Then
            If IsFurling = True Then
                Return 0.99
            Else
                Return 1
            End If
        Else
            Return 1
        End If
    End Function

    Function CalcSailLuff()
        Return Round(MaxHoist * MaxHoistFactor(), 2)
    End Function

    Function CalcLPFromFoot()
        Return Round(Sin(HeadAng) * Leech, 2)
    End Function

    Function S()
        Return (Luff + Leech + Foot) / 2
    End Function

    Function HeadAng()
        Return 2 * (Atan(Sqrt(((S() - Leech) * (S() - Luff)) / (S() * (S() - Foot)))))
    End Function
End Class
